# import os
from openai import OpenAI


while True:
    print('=====开始=====')

    content = input('请输入：')


    print('1')
    # 构造 client
    client = OpenAI(
        # api_key=os.environ.get("HUNYUAN_API_KEY"),  # 混元 APIKey
        api_key= 'sk-ZZrL7CthwBAzlUnImsdvGteAltKWaLnRuUNGQMdBSgenJSEA',
        base_url="https://api.hunyuan.cloud.tencent.com/v1",  # 混元 endpoint
    )
    print('2')
    completion = client.chat.completions.create(
        model="hunyuan-turbos-latest",
        messages=[
            {
                "role": "user",
                # "content": "Say this is a test."
                "content": content
            }
        ],
        extra_body={
            "enable_enhancement": True,  # <- 自定义参数
        },
    )
    print('3')
    # print(completion.choices[0].message.content)
    # cc0 = str(completion.choices[0])
    # print(cc0)
    # print('===========')
    cc0mc = str(completion.choices[0].message.content)
    print(cc0mc)
    # print('===========')
    # cc0m = str(completion.choices[0].message)
    # print(cc0m)
    text = content + '\n' + '\n' + cc0mc + '\n' + '\n'
    open('腾讯混元.txt', 'a', encoding='utf-8').write(text)

    print('=====结束======')





# key = 'sk-ZZrL7CthwBAzlUnImsdvGteAltKWaLnRuUNGQMdBSgenJSEA'









# 'SecretId:AKIDGNOCnFUVIrDMH55tUr21nLgokU0JOI0W
# SecretKey:OZWGn8GArQozwgEZYKsCJCrMpEShz62o'

"""
SecretId:AKIDGNOCnFUVIrDMH55tUr21nLgokU0JOI0W
SecretKey:OZWGn8GArQozwgEZYKsCJCrMpEShz62o
"""
